import React from 'react';
import Badge from './Badge';
import { StatusType, ModelType, DataType, TaskType, QualityType, BadgeVariant } from '@/store/types';

// 通用状态徽章生成器
export function getStatusBadge(status: StatusType): React.ReactElement {
  const statusMap: Record<StatusType, { variant: BadgeVariant; label: string }> = {
    'running': { variant: 'info', label: '运行中' },
    'completed': { variant: 'success', label: '已完成' },
    'pending': { variant: 'warning', label: '待执行' },
    'failed': { variant: 'error', label: '失败' },
    'paused': { variant: 'default', label: '已暂停' },
    'ready': { variant: 'success', label: '就绪' },
    'archived': { variant: 'default', label: '已归档' },
    'published': { variant: 'info', label: '已发布' },
    'training': { variant: 'warning', label: '训练中' },
    'processing': { variant: 'warning', label: '处理中' },
    'error': { variant: 'error', label: '错误' },
  };

  const config = statusMap[status] || { variant: 'default' as BadgeVariant, label: status };
  return <Badge variant={config.variant}>{config.label}</Badge>;
}

// 模型类型徽章生成器
export function getModelTypeBadge(type: ModelType): React.ReactElement {
  const typeMap: Record<ModelType, { variant: BadgeVariant; label: string }> = {
    'large': { variant: 'info', label: '大模型' },
    'small': { variant: 'success', label: '小模型' },
  };

  const config = typeMap[type];
  return <Badge variant={config.variant}>{config.label}</Badge>;
}

// 数据类型徽章生成器
export function getDataTypeBadge(type: DataType): React.ReactElement {
  const typeMap: Record<DataType, { variant: BadgeVariant; label: string }> = {
    'image': { variant: 'info', label: '图像' },
    'sequence': { variant: 'success', label: '序列' },
    'text': { variant: 'warning', label: '文本' },
    'mixed': { variant: 'default', label: '混合' },
  };

  const config = typeMap[type];
  return <Badge variant={config.variant}>{config.label}</Badge>;
}

// 任务类型徽章生成器
export function getTaskTypeBadge(type: TaskType): React.ReactElement {
  const typeMap: Record<TaskType, { variant: BadgeVariant; label: string }> = {
    'incremental_learning': { variant: 'info', label: '增量学习' },
    'collaborative_evolution': { variant: 'success', label: '协同进化' },
    'quantization': { variant: 'warning', label: '模型量化' },
  };

  const config = typeMap[type];
  return <Badge variant={config.variant}>{config.label}</Badge>;
}

// 质量徽章生成器
export function getQualityBadge(quality: QualityType): React.ReactElement {
  const qualityMap: Record<QualityType, { variant: BadgeVariant; label: string }> = {
    'high': { variant: 'success', label: '高质量' },
    'medium': { variant: 'warning', label: '中等质量' },
    'low': { variant: 'error', label: '低质量' },
  };

  const config = qualityMap[quality];
  return <Badge variant={config.variant}>{config.label}</Badge>;
} 